'use strict';

const Controllor = require('egg').Controller;

class CurlControllor extends Controllor {
  async getCurl() {
    const res = await this.ctx.curl('http://127.0.0.1:7001/', {
      dataType: 'text',
    });
    this.ctx.body = {
      status: 200,
      data: res.data,
    };
  }

  async postCurl() {
    const res = await this.ctx.curl('http://127.0.0.1:7001/user/login', {
      dataType: 'json',
      contentType: 'json',
      method: 'POST',
      body: this.ctx.request.body,
    });
    console.log(res);
    this.ctx.body = {
      status: 200,
      data: res.data,
    };
  }
}

module.exports = CurlControllor;
